PROJECT(vtkSequenceIO)

IF (IGSIO_SEQUENCEIO_ENABLE_MKV)
  FIND_PACKAGE(libwebm REQUIRED)
ENDIF()

# --------------------------------------------------------------------------
# Configure library
SET(${PROJECT_NAME}_INCLUDE_DIRS
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
  ${vtkIGSIOCommon_INCLUDES}
  CACHE INTERNAL ""
  )

SET(${PROJECT_NAME}_SRCS
  vtkIGSIOSequenceIO.cxx
  vtkIGSIOSequenceIOBase.cxx
  vtkIGSIOMetaImageSequenceIO.cxx
  vtkIGSIONrrdSequenceIO.cxx
  )

SET(${PROJECT_NAME}_HDRS
  vtkIGSIOSequenceIO.h
  vtkIGSIOSequenceIOBase.h
  vtkIGSIOMetaImageSequenceIO.h
  vtkIGSIONrrdSequenceIO.h
  )

SET(${PROJECT_NAME}_LIBS
  vtkCommonCore
  vtkCommonDataModel
  vtksys
  vtkIOImage
  vtkIGSIOCommon
  )

SET(${PROJECT_NAME}_LIBS_PRIVATE
  )

IF (IGSIO_SEQUENCEIO_ENABLE_MKV)
  SET(MKV_SRCS
    vtkIGSIOMkvSequenceIO.cxx
    )
  SET(MKV_HDRS
    vtkIGSIOMkvSequenceIO.h
    )

  LIST(APPEND ${PROJECT_NAME}_INCLUDE_DIRS
    ${LIBWEBM_INCLUDE_DIRS}
    )
  LIST(APPEND ${PROJECT_NAME}_SRCS
    ${MKV_SRCS}
    )
  LIST(APPEND ${PROJECT_NAME}_HDRS
    ${MKV_HDRS}
    )

  LIST(APPEND ${PROJECT_NAME}_LIBS_PRIVATE
    ${LIBWEBM_LIBRARIES}
    )

ENDIF()

#-----------------------------------------------------------------------------
# Create the library
IF(MSVC OR ${CMAKE_GENERATOR} MATCHES "Xcode")
  ADD_LIBRARY(${PROJECT_NAME} ${${PROJECT_NAME}_SRCS} ${${PROJECT_NAME}_HDRS})
ELSE()
  ADD_LIBRARY(${PROJECT_NAME} ${${PROJECT_NAME}_SRCS})
ENDIF()
TARGET_LINK_LIBRARIES(${PROJECT_NAME}
  PUBLIC ${${PROJECT_NAME}_LIBS}
  PRIVATE ${${PROJECT_NAME}_LIBS_PRIVATE}
  )

INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
  RUNTIME DESTINATION ${IGSIO_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
  LIBRARY DESTINATION ${IGSIO_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
  ARCHIVE DESTINATION ${IGSIO_INSTALL_LIB_DIR} COMPONENT Development)

FOREACH(p IN LISTS ${PROJECT_NAME}_INCLUDE_DIRS)
  TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${p}>)
ENDFOREACH()
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}>)

GENERATE_EXPORT_HEADER(${PROJECT_NAME})

SET_PROPERTY(GLOBAL APPEND PROPERTY IGSIO_TARGETS ${PROJECT_NAME})

SET(${PROJECT_NAME}_INCLUDE_DIRS ${${PROJECT_NAME}_INCLUDE_DIRS} CACHE INTERNAL "")

# --------------------------------------------------------------------------
# Testing
IF(BUILD_TESTING)
  ADD_SUBDIRECTORY(Testing)
ENDIF()
